package spynx.desl.runtime.impl;

import spynx.desl.runtime.IExecutionContext;
import spynx.desl.runtime.IRuntimeEntity;
import spynx.desl.runtime.IVariable;

public class Variable implements IVariable, IRuntimeEntity {

	private Object value;
	private String name;
	private boolean readonly;

	public Variable() {}
	
	public Variable(Object value) {
		this.value = value;
	}
	
	public Variable(String name, Object value) {
		this.name = name;
		this.value = value;
	}
	
	@Override
	public Object getValue() {
		return this.value;
	}

	@Override
	public void setValue(Object value) {
		this.value = value;
	}

	@Override
	public String getName() {
		return name != null && name.length() > 0 ? this.name : Integer.toHexString(this.hashCode());
	}

	@Override
	public void setName(String name) {
		this.name = name;
	}

	@Override
	public String toString() {
		return String.format("%s=%s", name, value);
	}

	
	@Override
	public boolean isPersist() {
		return false;
	}

	@Override
	public boolean isReadOnly() {
		return this.readonly;
	}

	@Override
	public void setReadOnly(boolean readonly) {
		this.readonly = readonly;
	}

	@Override
	public Object applyOperator(IExecutionContext context, String operator,
			Object... args) {
		// TODO Auto-generated method stub
		return null;
	}
}
